export const addCommas = (num: number | string, decimal: boolean = false) => {
  const str = num.toString().replace(/[^\d.-]/g, '')
  const floatNum = decimal ? parseFloat(str).toFixed(2) : parseFloat(str).toString()
  const arr = floatNum.split('.')
  const int = arr[0]
  const dec = arr[1] || ''
  const reg = /(\d)(?=(\d{3})+$)/g
  const result = int.replace(reg, '$1,')
  return result + (dec ? '.' + dec : '')
}
